package recycle.controller;

import recycle.pojo.Orderdetail;
import recycle.service.OrderdetailService;
import recycle.utils.Page;
import recycle.vo.OrderdetailParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 描述：订单详情表 控制器
* @author 孙冉
* @date 2019/07/22
*/
@RestController
@RequestMapping("/orderdetail")
public class OrderdetailController{
	@Resource
	private OrderdetailService orderdetailService;
 	
 	@RequestMapping("/findById.json")
    public Orderdetail findById(Integer orderDetailId){
        Orderdetail result = null;
        try {
            result = orderdetailService.findById(orderDetailId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：获取所有的Orderdetail对象
     */
    @RequestMapping("/findAll.json")
    public List<Orderdetail> findAll(){
        List<Orderdetail> result = null;
        try {
            result = orderdetailService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：新增保存Orderdetail对象
     */
    @RequestMapping("/save.json")
    public Map save(Orderdetail orderdetail){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存订单详情表失败");
        try {
            if(orderdetailService.save(orderdetail)>0){
                result.put("flag",true);
                result.put("msg","保存订单详情表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：根据主键删除订单详情表对象
     * @param orderDetailId
     */
    @RequestMapping("/delete.json")
    public Map delete(Integer orderDetailId){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存订单详情表失败");
        try {
            if(orderdetailService.delete(orderDetailId)>0){
                result.put("flag",true);
                result.put("msg","保存订单详情表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：更新订单详情表对象
     */
    @RequestMapping("/update.json")
    public Map update(Orderdetail orderdetail){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","更新订单详情表失败");
        try {
            if( orderdetailService.update(orderdetail)>0){
                result.put("flag",true);
                result.put("msg","更新订单详情表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;

    }

    /**
     * 根据不确定的条件，动态查询
     */
    @RequestMapping("/query.json")
    public List<Orderdetail> query(OrderdetailParam param){
        List<Orderdetail> result = null;
        try {
            result = orderdetailService.query(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    @RequestMapping("/queryByPage.json")
    public Page queryByPage(OrderdetailParam param){
        Page result = null;
        try {
            result = orderdetailService.queryByPage(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
 }
